<?php

namespace App\Models\Cruise;

use App\Models\BaseModel;
use App\Models\Shop\ShopModel;
use App\Models\Traits\KfUid;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;

class CruiseCheckSelfTaskCompanyMappingModel extends BaseModel
{
    use KfUid;

    protected $table    = 'cruise_check_self_task_company_mappings';
    protected $fillable = [
        'shopId',
        'cruiseCheckCompanyId',
        'taskId',
    ];

    const RULE_DAY = 1;

    const RULE_TEXT = [
        self::RULE_DAY => '每日一检',
    ];

    /**
     * @return HasOne
     */
    public function cruiseCheckCompanyRel(): HasOne
    {
        return $this->hasOne(CruiseCheckCompanyModel::class, "id", "cruiseCheckCompanyId");
    }

    public function cruiseCheckShopRel(): HasOne
    {
        return $this->hasOne(ShopModel::class, "id", "shopId");
    }

    /**
     * @return HasOne
     */
    public function cruiseCheckSelfTaskRel(): HasOne
    {
        return $this->hasOne(CruiseCheckSelfTaskModel::class, "id", "taskId");
    }

    /**
     * @return HasMany
     */
    public function cruiseCheckSelfDetailRel(): HasMany
    {
        return $this->hasMany(CruiseCheckSelfDetailModel::class, "cruiseCheckCompanyId", "cruiseCheckCompanyId");
    }
}
